/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Samuel.Util;

import com.jgoodies.looks.plastic.PlasticLookAndFeel;
import com.jgoodies.looks.plastic.PlasticTheme;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.Locale;
import javax.swing.ImageIcon;
import javax.swing.UIManager;
import javax.swing.plaf.FontUIResource;
import twaver.TWaverConst;
import twaver.TWaverUtil;

/**
 *
 * @author samuel
 */
public class PathLoad {

    private static final String IMAGEURL_PATH_STRING = "/Samuel/Image/";

    private PathLoad() {
    }

    /**
     *
     * @param imageName
     * @return Full image Path
     */
    public static String getImageURL(String imageName) {
        return IMAGEURL_PATH_STRING + imageName;
    }

    public static TexturePaint createTexturePaint(String imageURL) {
        return createTexturePaint(TWaverUtil.getImage(imageURL));
    }

    public static TexturePaint createTexturePaint(Image image) {
        int imageWidth = image.getWidth(null);
        int imageHeight = image.getHeight(null);
        BufferedImage bi = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2d = bi.createGraphics();
        g2d.drawImage(image, 0, 0, null);
        g2d.dispose();
        return new TexturePaint(bi, new Rectangle(0, 0, imageWidth, imageHeight));
    }

    public static Image getImage(String imageName) {
        return TWaverUtil.getImage(getImageURL(imageName));
    }

    public static ImageIcon getImageIcon(String imageName) {
        return TWaverUtil.getImageIcon(getImageURL(imageName));
    }

    public static void setupLookAndFeel() {
        Locale.setDefault(TWaverConst.EN_US);
        TWaverUtil.setLocale(TWaverConst.EN_US);
        PlasticTheme theme = new com.jgoodies.looks.plastic.theme.ExperienceGreen() {

            @Override
            public FontUIResource getControlTextFont() {
                return new FontUIResource(new Font("Calibri", Font.PLAIN, 11));
            }
        };
        PlasticLookAndFeel.setPlasticTheme(theme);
        try {
            UIManager.setLookAndFeel("com.jgoodies.looks.plastic.Plastic3DLookAndFeel");
        } catch (Exception ex) {
        }
    }
}
